from rest_framework import serializers

from apps.goods.models import SKUImage, SKU


class ImageSeriazlier(serializers.ModelSerializer):
    """图片管理序列化器"""

    # 返回图片关联的sku的id
    sku = serializers.PrimaryKeyRelatedField(read_only=True)

    # 模型序列化器
    class Meta:
        model = SKUImage
        fields = ("id","sku","image")


class SKUSeriazlier(serializers.ModelSerializer):
    """sku序列化器"""
    class Meta:
        model = SKU
        fields = ("id","name")